import com.demo.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class GetBeanExample2 {
    public static void main(String[] args) {
        //1.获取容器对象
        ApplicationContext context =
                new ClassPathXmlApplicationContext("spring-config.xml");
        //2.获取 Bean
        UserService userService = context.getBean("user",UserService.class);
        //3.使用 Bean
        userService.sayHi();
    }
}
